﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

	<!-- All the following is required to Re-Style the ScrollViewer, see 
             http://msdn2.microsoft.com/en-us/library/aa970847(VS.85).aspx
             http://msdn2.microsoft.com/en-us/library/ms742173(VS.85).aspx
             for the default Stles that the ScrollViewer has out of the box
         -->

	<!-- Brushes used in Styling of ScrollViewer -->
	<SolidColorBrush x:Key="DisabledForegroundBrush" Color="#888" />
	<SolidColorBrush x:Key="ThumbBackgroundBrush" Color="Transparent" />
	<SolidColorBrush x:Key="ThumbBorderBrush" Color="WhiteSmoke" />
	<SolidColorBrush x:Key="TrackBackgroundBrush" Color="Transparent" />
	<SolidColorBrush x:Key="ArrowFillBrush" Color="WhiteSmoke" />
	<SolidColorBrush x:Key="ArrowStrokeBrush" Color="WhiteSmoke" />
	<LinearGradientBrush x:Key="PressedBrush" StartPoint="0,0" EndPoint="0,1">
		<GradientBrush.GradientStops>
			<GradientStopCollection>
				<GradientStop Color="#BBB" Offset="0.0" />
				<GradientStop Color="#EEE" Offset="0.1" />
				<GradientStop Color="#EEE" Offset="0.9" />
				<GradientStop Color="#FFF" Offset="1.0" />
			</GradientStopCollection>
		</GradientBrush.GradientStops>
	</LinearGradientBrush>
	<LinearGradientBrush x:Key="MouseOverBrush" StartPoint="0,0" EndPoint="0,1">
		<GradientBrush.GradientStops>
			<GradientStopCollection>
				<GradientStop Color="#888" Offset="0.0" />
				<GradientStop Color="#AAA" Offset="0.1" />
				<GradientStop Color="#AAA" Offset="0.9" />
				<GradientStop Color="#BBB" Offset="1.0" />
			</GradientStopCollection>
		</GradientBrush.GradientStops>
	</LinearGradientBrush>

	<!-- SrollViewer ScrollBar Repeat Buttons (at each end) -->
	<Style x:Key="ScrollBarLineButton" TargetType="{x:Type RepeatButton}">
		<Setter Property="SnapsToDevicePixels" Value="True" />
		<Setter Property="OverridesDefaultStyle" Value="true" />
		<Setter Property="Focusable" Value="false" />
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type RepeatButton}">
					<Path x:Name="Arrow" Fill="{StaticResource ArrowFillBrush}"
							HorizontalAlignment="Center" VerticalAlignment="Center"
							Data="{Binding Path=Content, RelativeSource={RelativeSource TemplatedParent}}"
							Stretch="Fill" Margin="2" Stroke="{StaticResource ArrowStrokeBrush}" />
					<ControlTemplate.Triggers>
						<Trigger Property="IsPressed" Value="true">
							<Setter TargetName="Arrow" Property="Fill"
									Value="{StaticResource PressedBrush}" />
						</Trigger>
						<Trigger Property="IsMouseOver" Value="true">
							<Setter TargetName="Arrow" Property="Fill"
									Value="{StaticResource MouseOverBrush}" />
						</Trigger>
						<Trigger Property="IsEnabled" Value="false">
							<Setter Property="Foreground"
									Value="{StaticResource DisabledForegroundBrush}" />
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<!-- SrollViewer ScrollBar Repeat Buttons (The part in the middle, 
             not the thumb the long area between the buttons ) -->
	<Style x:Key="ScrollBarPageButton" TargetType="{x:Type RepeatButton}">
		<Setter Property="SnapsToDevicePixels" Value="True" />
		<Setter Property="OverridesDefaultStyle" Value="true" />
		<Setter Property="IsTabStop" Value="false" />
		<Setter Property="Focusable" Value="false" />
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type RepeatButton}">
					<Border Background="#01000000" CornerRadius="0" />
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<!-- ScrollViewer ScrollBar Thumb, that part that can be dragged
            up/down or left/right Buttons -->
	<Style x:Key="ScrollBarThumb" TargetType="{x:Type Thumb}">
		<Setter Property="SnapsToDevicePixels" Value="True" />
		<Setter Property="OverridesDefaultStyle" Value="true" />
		<Setter Property="IsTabStop" Value="false" />
		<Setter Property="Focusable" Value="false" />
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type Thumb}">
					<Border CornerRadius="0" Background="WhiteSmoke"
							BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1" />
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<ControlTemplate x:Key="VerticalScrollBar" TargetType="{x:Type ScrollBar}">
		<Grid>
			<Grid.RowDefinitions>
				<RowDefinition MaxHeight="15" />
				<!--<RowDefinition Height="0.00001*" />-->
				<RowDefinition />
				<RowDefinition MaxHeight="15" />
			</Grid.RowDefinitions>
			<RepeatButton Grid.Row="0" Style="{StaticResource ScrollBarLineButton}" Height="15"
					Command="ScrollBar.LineUpCommand" Content="M 0 0.5 L 1 0.5 L 0.5 0 Z" />
			<Border CornerRadius="0" Background="{StaticResource TrackBackgroundBrush}" Grid.Row="1"
					Margin="2">
				<Track Name="PART_Track" Grid.Row="1" IsDirectionReversed="true">
					<Track.DecreaseRepeatButton>
						<RepeatButton Style="{StaticResource ScrollBarPageButton}"
								Command="ScrollBar.PageUpCommand" />
					</Track.DecreaseRepeatButton>
					<Track.Thumb>
						<Thumb Style="{StaticResource ScrollBarThumb}" Margin="1,0"
								Background="{StaticResource ThumbBackgroundBrush}"
								BorderBrush="{StaticResource ThumbBorderBrush}" />
					</Track.Thumb>
					<Track.IncreaseRepeatButton>
						<RepeatButton Style="{StaticResource ScrollBarPageButton}"
								Command="ScrollBar.PageDownCommand" />
					</Track.IncreaseRepeatButton>
				</Track>
			</Border>
			<RepeatButton Grid.Row="3" Style="{StaticResource ScrollBarLineButton}" Height="15"
					Command="ScrollBar.LineDownCommand" Content="M 0 0 L 0.5 0.5 L 1 0 Z" />
		</Grid>
	</ControlTemplate>

	<!-- HorizontalScrollBar Template using the previously created Templates -->
	<ControlTemplate x:Key="HorizontalScrollBar" TargetType="{x:Type ScrollBar}">
		<Grid>
			<Grid.ColumnDefinitions>
				<ColumnDefinition MaxWidth="15" />
				<!--<ColumnDefinition Width="0.00001*" />-->
				<ColumnDefinition />
				<ColumnDefinition MaxWidth="15" />
			</Grid.ColumnDefinitions>
			<RepeatButton Grid.Column="0" Style="{StaticResource ScrollBarLineButton}" Width="15"
					Command="ScrollBar.LineLeftCommand" Content="M 0.5 0 L 0.5 1 L 0 0.5 Z" />
			<Border CornerRadius="0" Background="{StaticResource TrackBackgroundBrush}"
					Grid.Column="1" Margin="2" BorderBrush="WhiteSmoke" BorderThickness="1">
				<Track Name="PART_Track" IsDirectionReversed="False">
					<Track.DecreaseRepeatButton>
						<RepeatButton Style="{StaticResource ScrollBarPageButton}"
								Command="ScrollBar.PageLeftCommand" />
					</Track.DecreaseRepeatButton>
					<Track.Thumb>
						<Thumb Style="{StaticResource ScrollBarThumb}"
								Background="{StaticResource ThumbBackgroundBrush}"
								BorderBrush="{StaticResource ThumbBorderBrush}" />
					</Track.Thumb>
					<Track.IncreaseRepeatButton>
						<RepeatButton Style="{StaticResource ScrollBarPageButton}"
								Command="ScrollBar.PageRightCommand" />
					</Track.IncreaseRepeatButton>
				</Track>
			</Border>
			<RepeatButton Grid.Column="3" Style="{StaticResource ScrollBarLineButton}" Width="15"
					Command="ScrollBar.LineRightCommand" Content="M 0 0 L 0.5 0.5 L 0 1 Z" />
		</Grid>
	</ControlTemplate>

	<!-- Style for overall  ScrollBar -->
	<Style x:Key="{x:Type ScrollBar}" TargetType="{x:Type ScrollBar}">
		<Setter Property="SnapsToDevicePixels" Value="True" />
		<Setter Property="OverridesDefaultStyle" Value="true" />
		<Style.Triggers>
			<Trigger Property="Orientation" Value="Horizontal">
				<Setter Property="Width" Value="Auto" />
				<Setter Property="Height" Value="15" />
				<Setter Property="Template" Value="{StaticResource HorizontalScrollBar}" />
			</Trigger>
			<Trigger Property="Orientation" Value="Vertical">
				<Setter Property="Width" Value="15" />
				<Setter Property="Height" Value="Auto" />
				<Setter Property="Template" Value="{StaticResource VerticalScrollBar}" />
			</Trigger>
		</Style.Triggers>
	</Style>

	<!-- Style for overall  ScrollViewer -->
	<Style x:Key="{x:Type ScrollViewer}" TargetType="{x:Type ScrollViewer}">
		<Setter Property="OverridesDefaultStyle" Value="True" />
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type ScrollViewer}">
					<Grid>
						<Grid.ColumnDefinitions>
							<ColumnDefinition />
							<ColumnDefinition Width="Auto" />
						</Grid.ColumnDefinitions>
						<Grid.RowDefinitions>
							<RowDefinition />
							<RowDefinition Height="Auto" />
						</Grid.RowDefinitions>
						<ScrollContentPresenter Cursor="{TemplateBinding Cursor}"
								Margin="{TemplateBinding Padding}"
								ContentTemplate="{TemplateBinding ContentTemplate}" />
						<ScrollBar Name="PART_VerticalScrollBar"
								Value="{TemplateBinding VerticalOffset}" Grid.Column="1"
								Maximum="{TemplateBinding ScrollableHeight}"
								ViewportSize="{TemplateBinding ViewportHeight}"
								Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
								Margin="2,0,0,0" />
						<ScrollBar Name="PART_HorizontalScrollBar" Orientation="Horizontal"
								Grid.Row="1" Value="{TemplateBinding HorizontalOffset}"
								Maximum="{TemplateBinding ScrollableWidth}"
								ViewportSize="{TemplateBinding ViewportWidth}"
								Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
								Margin="0,2,0,0" />

					</Grid>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

</ResourceDictionary>